<ion-content>
    <ion-refresher [enabled]="loaded" (ionRefresh)="refresh($event)">
        <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
    </ion-refresher>
    <core-loading [hideUntil]="loaded" class="core-loading-center">
        <ion-item *ngIf="showMyEntriesToggle">
            <ion-label>{{ 'addon.blog.showonlyyourentries' | translate }}</ion-label>
            <ion-toggle [(ngModel)]="onlyMyEntries" (ionChange)="onlyMyEntriesToggleChanged(onlyMyEntries)"></ion-toggle>
        </ion-item>
        <core-empty-box *ngIf="entries && entries.length == 0" icon="fa-newspaper-o" [message]="'addon.blog.noentriesyet' | translate"></core-empty-box>
        <ng-container *ngFor="let entry of entries">
            <ion-card *ngIf="!onlyMyEntries || entry.userid == currentUserId">
                <ion-item text-wrap>
                    <ion-avatar core-user-avatar [user]="entry.user" item-start [courseId]="entry.courseid"></ion-avatar>
                    <h2>
                        <core-format-text [text]="entry.subject" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId"></core-format-text>
                        <ion-note float-end padding-left text-end>
                            {{ 'addon.blog.' + entry.publishTranslated | translate}}
                        </ion-note>
                    </h2>
                    <p>
                        <ion-note float-end padding-left text-end>
                            {{entry.created | coreDateDayOrTime}}
                        </ion-note>
                        {{entry.user && entry.user.fullname}}
                    </p>
                </ion-item>
                <ion-card-content>
                    <ion-item>
                        <core-format-text [text]="entry.summary" [component]="this.component" [componentId]="entry.id" [contextLevel]="contextLevel" [contextInstanceId]="contextInstanceId"></core-format-text>
                    </ion-item>
                    <ion-item text-wrap *ngIf="tagsEnabled && entry.tags && entry.tags.length > 0">
                        <div item-start>{{ 'core.tag.tags' | translate }}:</div>
                        <core-tag-list [tags]="entry.tags"></core-tag-list>
                    </ion-item>
                    <ion-item *ngIf="commentsEnabled">
                        <core-comments [component]="this.component" [itemId]="entry.id" area="format_blog" [instanceId]="entry.userid" contextLevel="user"></core-comments>
                    </ion-item>
                    <core-file *ngFor="let file of entry.attachmentfiles" [file]="file" [component]="this.component" [componentId]="entry.id"></core-file>
                    <a ion-item *ngIf="entry.uniquehash" [href]="entry.uniquehash" core-link>{{ 'addon.blog.linktooriginalentry' | translate }}</a>
                </ion-card-content>
                <ion-row text-center>
                    <ion-col *ngIf="entry.lastmodified > entry.created">
                        <ion-note>
                            <ion-icon name="time"></ion-icon> {{entry.lastmodified | coreTimeAgo}}
                        </ion-note>
                    </ion-col>
                </ion-row>
            </ion-card>
        </ng-container>
        <core-infinite-loading [enabled]="canLoadMore" (action)="loadMore($event)" [error]="loadMoreError"></core-infinite-loading>
    </core-loading>
</ion-content>
